package com.ke.config;

import com.ke.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 配置拦截路径,用户未登录不可访问的方法
 * @author bochen
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    MyInterceptor myInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor).addPathPatterns("/article/loadPic")
               .addPathPatterns("/user/findUser")
                .addPathPatterns("/user/uploadPic")
                .addPathPatterns("/user/updateUSer")
                .addPathPatterns("/cart/**")
                .addPathPatterns("/article/insert")
                .addPathPatterns("/article/addFactority")
                .addPathPatterns("/article/verifyFactority")
                .addPathPatterns("/article/findByIdUserLogin")
                .addPathPatterns("/article/findAllFavorites")
                .addPathPatterns("/article/addArticleCommend")
                .addPathPatterns("/articleCart/**")
                .addPathPatterns("/articleOrder/**")
                .excludePathPatterns("/articleOrder/returnMessage")
                .addPathPatterns("/ali/**")
                .addPathPatterns("/video/addvideo")
                .excludePathPatterns("/ali/notifyPay")
                .addPathPatterns("/order/**")
                .addPathPatterns("/cart/addCart/{pid}")
                .addPathPatterns("/article/insert")
       .addPathPatterns("/video/addcollect")
        .addPathPatterns("/video/addcomment")
       /* .addPathPatterns("/video/addfile")*/
        .addPathPatterns("/video/addvideo");


    }

}
